package com.slipper.codeless.resolve.query;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class LeftJoinQuery {
    private String alias; // 同义词
    private String sourceAlias;
    private String sourceFieldName; // 来源字段
    private String targetId; // 目标ID
    private String targetTableName; // 目标表名
    private String targetPrimaryKey; // 目标表主键名
    private String sortField; // 排序字段
    private String sortType; // 排序方式
    private Map<String, String> targetFieldMap = new HashMap<>(); // key: 目标表取值字段, value: 查询返回字段
    private List<Condition> conditionList = new ArrayList<>(); // 查询条件信息
    private List<Condition> orConditionList = new ArrayList<>(); // or查询字段信息
    private List<Condition> onConditionList = new ArrayList<>(); // on查询字段信息

    public String getAlias() {
        return alias;
    }

    public void setAlias(String alias) {
        this.alias = alias;
    }

    public String getSourceAlias() {
        return sourceAlias;
    }

    public void setSourceAlias(String sourceAlias) {
        this.sourceAlias = sourceAlias;
    }

    public String getSourceFieldName() {
        return sourceFieldName;
    }

    public void setSourceFieldName(String sourceFieldName) {
        this.sourceFieldName = sourceFieldName;
    }

    public String getTargetId() {
        return targetId;
    }

    public void setTargetId(String targetId) {
        this.targetId = targetId;
    }

    public String getTargetTableName() {
        return targetTableName;
    }

    public void setTargetTableName(String targetTableName) {
        this.targetTableName = targetTableName;
    }

    public String getTargetPrimaryKey() {
        return targetPrimaryKey;
    }

    public void setTargetPrimaryKey(String targetPrimaryKey) {
        this.targetPrimaryKey = targetPrimaryKey;
    }

    public String getSortField() {
        return sortField;
    }

    public void setSortField(String sortField) {
        this.sortField = sortField;
    }

    public String getSortType() {
        return sortType;
    }

    public void setSortType(String sortType) {
        this.sortType = sortType;
    }

    public void addFieldMapping(String sourceName, String targetName) {
        this.targetFieldMap.put(sourceName, targetName);
    }

    public Map<String, String> getTargetFieldMap() {
        return targetFieldMap;
    }

    public void setTargetFieldMap(Map<String, String> targetFieldMap) {
        this.targetFieldMap = targetFieldMap;
    }

    public List<Condition> getConditionList() {
        return conditionList;
    }

    public void setConditionList(List<Condition> conditionList) {
        this.conditionList = conditionList;
    }

    public List<Condition> getOrConditionList() {
        return orConditionList;
    }

    public void setOrConditionList(List<Condition> orConditionList) {
        this.orConditionList = orConditionList;
    }

    public List<Condition> getOnConditionList() {
        return onConditionList;
    }

    public void setOnConditionList(List<Condition> onConditionList) {
        this.onConditionList = onConditionList;
    }

    public void addCondition(String fieldName, String fieldType, String matchMode, Object matchValue) {
        this.conditionList.add(new Condition(fieldName, fieldType, matchMode, matchValue));
    }

    public void addOrCondition(String fieldName, String fieldType, String matchMode, Object matchValue) {
        this.orConditionList.add(new Condition(fieldName, fieldType, matchMode, matchValue));
    }

    public void addOnCondition(String fieldName, String fieldType, String matchMode, Object matchValue) {
        this.onConditionList.add(new Condition(fieldName, fieldType, matchMode, matchValue));
    }
}
